import ProLayout from '@ant-design/pro-layout';
import { connect } from 'umi';
import styles from './HeaderLayout.less'
import RightContent from '@/components/GlobalHeader/RightContent';
import React, { useEffect } from 'react';
import logo from '../asserts/favicon.png';
import { ELDefaultFooter } from '@/components/PageFooter'


const HeaderLayout = (props) => {
    const {
        children,
        settings,
        dispatch
    } = props;

    useEffect(() => {
        if (dispatch) {
            dispatch({
                type: 'user/getMyInfo',
            });
            dispatch({
                type: 'enterprise/getUserCurrentEnterprise',
            });
        }
    }, []);

    // console.log(props)

    return (
        <ProLayout
            className={styles.headerLayout}
            title={"优里"}
            logo={logo}
            // pageTitleRender={pageTitleRender}
            rightContentRender={() => <RightContent />}
            footerRender={() => <ELDefaultFooter />}

            {...settings}
            layout="top"
        >
            {children}
        </ProLayout>
    );

}



const mapStateToProps = ({ global, settings }) => {
    return {
        collapsed: global.collapsed,
        myInfo: global.myInfo,
        settings,
    }
}

export default connect(mapStateToProps)(HeaderLayout);